package com.corgi.webservice.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.ws.config.annotation.WsConfigurerAdapter;
import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition;
import org.springframework.ws.wsdl.wsdl11.Wsdl11Definition;
import org.springframework.xml.xsd.SimpleXsdSchema;
import org.springframework.xml.xsd.XsdSchema;

/**
 * @title: WebServiceConfiguration
 * @description: web service配置类
 * @author: dengmiao
 * @create: 2019-10-11 17:48
 **/
@Configuration
public class WebServiceConfiguration extends WsConfigurerAdapter {

	@Bean("user")
	@Autowired
	public Wsdl11Definition userWsdl11Definition(XsdSchema userXsdSchema) {
		DefaultWsdl11Definition userWsdl11Definition = new DefaultWsdl11Definition();

		userWsdl11Definition.setPortTypeName("UserServicePort");
		userWsdl11Definition.setLocationUri("/web-services");
		userWsdl11Definition.setTargetNamespace("http://www.segmentfault.com/schemas");
		userWsdl11Definition.setSchema(userXsdSchema);

		return userWsdl11Definition;
	}

	@Bean
	public XsdSchema xsdSchema() {
		return new SimpleXsdSchema(new ClassPathResource("META-INF/schemas/user.xsd"));
	}
}
